<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib  uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE HTML>
<html> 
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<LINK rel="Bookmark" href="/favicon.ico" >
<LINK rel="Shortcut Icon" href="/favicon.ico" />
<!--[if lt IE 9]>
<script type="text/javascript" src="<%=request.getContextPath() %>/assets/lib/html5.js"></script>
<script type="text/javascript" src="<%=request.getContextPath() %>/assets/lib/respond.min.js"></script>
<script type="text/javascript" src="<%=request.getContextPath() %>/assets/lib/PIE_IE678.js"></script>
<![endif]-->
<link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/static/h-ui/css/H-ui.min.css" />
<link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/static/h-ui.admin/css/H-ui.admin.css" />
<link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/static/Hui-iconfont/1.0.8/iconfont.css" />
<link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/static/icheck/icheck.css" />
<link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/static/h-ui.admin/skin/default/skin.css" id="skin" />
<link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/static/h-ui.admin/css/style.css" />

<link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/static/zTree/v3/css/zTreeStyle/zTreeStyle.css" />


<!--[if IE 6]>
<script type="text/javascript" src="http://lib.h-ui.net/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->
<title>编辑该角色对应的菜单</title>
</head>
<body>
<article class="page-container">
	<form action="<%=request.getContextPath() %>/role/do_menu.do" method="post" class="form form-horizontal" id="form-add">
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3">菜单选择：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<div class="zTreeDemoBackground left">
					<ul id="treeDemo" class="ztree"></ul>
				</div>
			</div>
		</div>
		<div class="row cl">
			<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
				<input id="from_submit" class="btn btn-primary radius" type="button" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
				<button onClick="layer_close();" class="btn btn-default radius" type="button">&nbsp;&nbsp;取消&nbsp;&nbsp;</button>
			</div>
		</div>
	</form>
</article>

<!--_footer 作为公共模版分离出去--> 
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<script type="text/javascript" src="<%=request.getContextPath() %>/static/jquery/1.9.1/jquery-form.js"></script>  
<script type="text/javascript" src="<%=request.getContextPath() %>/static/layer/2.4/layer.js"></script> 
<script type="text/javascript" src="<%=request.getContextPath() %>/static/icheck/jquery.icheck.min.js"></script> 
<script type="text/javascript" src="<%=request.getContextPath() %>/static/jquery.validation/1.14.0/jquery.validate.min.js"></script> 
<script type="text/javascript" src="<%=request.getContextPath() %>/static/jquery.validation/1.14.0/validate-methods.js"></script> 
<script type="text/javascript" src="<%=request.getContextPath() %>/static/jquery.validation/1.14.0/messages_zh.min.js"></script> 
<script type="text/javascript" src="<%=request.getContextPath() %>/static/h-ui/js/H-ui.js"></script> 
<script type="text/javascript" src="<%=request.getContextPath() %>/static/h-ui.admin/js/H-ui.admin.js"></script>
<script type="text/javascript" src="<%=request.getContextPath() %>/static/zTree/v3/js/jquery.ztree.core-3.5.js"></script>
<script type="text/javascript" src="<%=request.getContextPath() %>/static/zTree/v3/js/jquery.ztree.excheck-3.5.js"></script> 
<script type="text/javascript">
$(function(){
	$('.skin-minimal input').iCheck({checkboxClass: 'icheckbox-blue',radioClass: 'iradio-blue',increaseArea: '20%'});
 
$("#from_submit").click(function(){
	var menu_id_str="";
	//获取 所有已经选中的 菜单id
	 var zTree = $.fn.zTree.getZTreeObj("treeDemo");
	 var nodes = zTree.getCheckedNodes(true);
	 for(var i=0; i<nodes.length;  i++) {
		  menu_id_str+=nodes[i].id+"_";
	 }
	 $.ajax({ type: 'POST', dataType: "json",url: "<%=request.getContextPath() %>/jsp/menu/updateRoleMenu.action?rid=${rid}&menu_id_str="+menu_id_str,
	     success: function(data){ 
	    	  alert(data.msg);
	     } 
	});		
	 
});

});
</script> 
 <script type="text/javascript">
		var setting = {
			view: {selectedMulti: false},
			check: {enable: true},
			data: {simpleData: {enable: true}}
			
		};
		function createTree() {
			$.ajax({ type: 'POST', dataType: "json",url: "<%=request.getContextPath() %>/jsp/menu/show_menu.action?rid=${rid}",
	     	success: function(data){
	     			$.fn.zTree.init($("#treeDemo"), setting, data);
	     		 }
			});
		}
		$(function(){createTree();});	
	</script>
</body>
</html>